<?php include "../public/header.php"?>
<?php include "../public/header_public.php"?>
<body class="laytp-container">
<div style="height: 45px"></div>
<div id="opt_nav">
</div>
<div id="dialog">
    <div class="page-title" id="page-title">
        <div class="page-title-con">
            <span class="title">选择往来单位账户信息</span>
            <div class="move_title"></div>
            <div class="page-title-opt-list">
                <button class="layui-btn layui-btn-sm btn-dark marginr5" type="button" id="submit">确定</button>
                <span id="page-close" class="page-close" onclick="layer_close()">×</span>
            </div>
        </div>
    </div>
</div>


<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
        <button class="layui-btn layui-btn-primary outbut" onclick="auth_but_func_add('新建')">
            <i class="layui-icon layui-icon-add-1"></i>新建
        </button>
    </div>
</script>

<script type="text/javascript">
    // 单选多选分类 默认单选 choose_type传值为多选
    var choose_type = getQueryVariable('choose_type');
    if(choose_type === undefined || choose_type === false){
        choose_type = 'radio';
    }else{
        choose_type = 'checkbox';
    }

    var parent_dom = getQueryVariable('dom');
    var parent_domkey = getQueryVariable('domkey');
    var parent_page = getQueryVariable('page');
    var parent_name = decodeURIComponent(getQueryVariable('name') || '') || '';


    var pub_dealid = 0;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;

        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        $("#cols_table").hide();
        $("#export_table").hide();
        table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_opt_get_dealcom_bank),where: {name:parent_name}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: ['', '', ''],filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,parseData: function(res){

                pub_dealid = res.data.dealid


                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.total,
                    "data": res.data.list
                };
            }
            ,cols: [[
                {type:choose_type,fixed:'left'}
                ,{type:'numbers',title:'序号',fixed:'left'}
                ,{field: 'isdea_name', title: '是否默认账户'}
                ,{field: 'zhangname', title: '账户名'}
                ,{field: 'bankname', title: '开户行及行号'}
                ,{field: 'banknum', title: '银行账号'}
                ,{field: 'explain', title: '备注'}
            ]]
            ,done : function(res, curr, count){
                // $(".layui-table-tool").remove()
                soulTable.render(this);
            }
        });
        listTableSearch(form, table);


        $('#submit').on('click', function () {
            var checkStatus = layui.table.checkStatus('datalist');
            var data = checkStatus.data;
            if(data.length < 1){
                facade.error("请选择数据");return false;
            }

            if(parent_page == '页面值'){

            }else if(parent_page == 'zhi_tou'){
                var bankstr = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].zhangname+''+data[0].banknum+'"><span class="choose_content">'+data[0].zhangname+''+data[0].banknum+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \'banknum\')">×</span></button>';
                $("#banknum" , parent.document).html(bankstr);
                parent.formValid('banknum');
                $("#bankname" , parent.document).val(data[0].bankname);
            }else if(parent_page == 'zhi_xiang'){
                var bankstr = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].zhangname+''+data[0].banknum+'"><span class="choose_content">'+data[0].zhangname+''+data[0].banknum+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \'banknum\')">×</span></button>';
                $("#banknum" , parent.document).html(bankstr);
                parent.formValid('banknum');
                $("#bankname" , parent.document).val(data[0].bankname);
            }else if(parent_page == 'zhi_enbao'){
                var bankstr = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].zhangname+''+data[0].banknum+'"><span class="choose_content">'+data[0].zhangname+''+data[0].banknum+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \'banknum\')">×</span></button>';
                $("#banknum" , parent.document).html(bankstr);
                parent.formValid('banknum');
                $("#bankname" , parent.document).val(data[0].bankname);
            }else if(parent_page == 'zhi_jintui'){
                var bankstr = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].zhangname+''+data[0].banknum+'"><span class="choose_content">'+data[0].zhangname+''+data[0].banknum+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \'banknum\')">×</span></button>';
                $("#banknum" , parent.document).html(bankstr);
                parent.formValid('banknum');
                $("#bankname" , parent.document).val(data[0].bankname);
            }else if(parent_page == 'zhi_lianjie'){
                var bankstr = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].zhangname+''+data[0].banknum+'"><span class="choose_content">'+data[0].zhangname+''+data[0].banknum+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \'banknum\')">×</span></button>';
                $("#banknum" , parent.document).html(bankstr);
                parent.formValid('banknum');
                $("#bankname" , parent.document).val(data[0].bankname);
            }else if(parent_page == 'zhi_jie'){
                var bankstr = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].zhangname+''+data[0].banknum+'"><span class="choose_content">'+data[0].zhangname+''+data[0].banknum+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \'banknum\')">×</span></button>';
                $("#banknum" , parent.document).html(bankstr);
                parent.formValid('banknum');
                $("#bankname" , parent.document).val(data[0].bankname);
            }else if(parent_page == 'zhi_daybao'){
                var bankstr = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].zhangname+''+data[0].banknum+'"><span class="choose_content">'+data[0].zhangname+''+data[0].banknum+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \'banknum\')">×</span></button>';
                $("#banknum" , parent.document).html(bankstr);
                parent.formValid('banknum');
                $("#bankname" , parent.document).val(data[0].bankname);
            }else if(parent_page == 'zhi_dayfu'){
                var bankstr = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].zhangname+''+data[0].banknum+'"><span class="choose_content">'+data[0].zhangname+''+data[0].banknum+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \'banknum\')">×</span></button>';
                $("#banknum" , parent.document).html(bankstr);
                parent.formValid('banknum');
                $("#bankname" , parent.document).val(data[0].bankname);
            }else if(parent_page == 'bond_jiao'){
                var bankstr = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].zhangname+''+data[0].banknum+'"><span class="choose_content">'+data[0].zhangname+''+data[0].banknum+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \'banknum\')">×</span></button>';
                $("#banknum" , parent.document).html(bankstr);
                parent.formValid('banknum');
                $("#bankname" , parent.document).val(data[0].bankname);
            }else if(parent_page == 'bond_fan'){
                var bankstr = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].zhangname+''+data[0].banknum+'"><span class="choose_content">'+data[0].zhangname+''+data[0].banknum+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \'banknum\')">×</span></button>';
                $("#banknum" , parent.document).html(bankstr);
                parent.formValid('banknum');
                $("#bankname" , parent.document).val(data[0].bankname);
            }else {

            }
            layer_close();
        });




    });



    function auth_but_func_add(){
        if(!pub_dealid){
            facade.error("请重新选择付款对象");return false;
        }
        openPageEdit('../dealcom/add_list.php?close=1&dealid='+pub_dealid);
    }
</script>
</body>
</html>
